package com.woniuxy.day10springmvc4.entity;

import lombok.Data;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;
import java.util.Date;

@Data
public class Student {
    @NotEmpty(message = "姓名不能为空")
    String name;
    @Max(value = 150,message = "最大不能超过150岁")
            @Min(0)
    Integer age;
    @Range(min = 0, max=1,message = "性别只有2种")
    int sex;//0是女 1是男
    @NotBlank(message = "电话号码不能为空")
            @Pattern(regexp = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$",message = "电话号码格式不正确")
    String telephone;
    @Email(message = "邮件格式不正确")
    String email;
    @DateTimeFormat(pattern = "yyyy-MM-dd",iso = DateTimeFormat.ISO.DATE)
            @Past
    Date birthDay;
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm",iso = DateTimeFormat.ISO.DATE_TIME)
    LocalDateTime createTime;
}
